package com.example.myapplication;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

import com.google.gson.Gson;

public class MainActivity2 extends AppCompatActivity {
    Handler handler;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        Gson gson = new Gson();
        handler = new Handler() {
            @Override
            public void handleMessage(@NonNull Message msg) {
                Log.i("tag","msg");
                String response = msg.obj.toString();
                Lunjiekou lunjiekou = gson.fromJson(response, Lunjiekou.class);
                ViewPager2 viewPager2 = findViewById(R.id.vaa);
                Lbou lbou = new Lbou(lunjiekou.getData().bannersList);
                viewPager2.setAdapter(lbou);
//                return false;
                                                                                                                             }
        };

        new util().GET("https://photo.vshare.site/online/test/banner","",handler);

        RadioGroup riqw = findViewById(R.id.ri_qw);
        riqw.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                RadioButton radioButton = group.findViewById(checkedId);
                Toast.makeText(MainActivity2.this,radioButton.getText(), Toast.LENGTH_SHORT).show();
            }
        });

        Button button=findViewById(R.id.sjdfh);
        button.setOnClickListener(new View.OnClickListener( ) {
            @Override
            public void onClick(View v) {

                EditText EditText=findViewById(R.id.editTextText2);
                String sf= EditText.getText().toString().trim();

                EditText EditText2=findViewById(R.id.editTextText3);
                String wsdac= EditText2.getText().toString().trim();

                EditText editTextText6=findViewById(R.id.editTextDate);
                String dfsf= editTextText6.getText().toString().trim();

                if (sf.matches("^[a-zA-Z0-9]{1,3}$") && wsdac.matches("^[a-zA-Z0-9]{1,3}$") && dfsf.matches("^[a-zA-Z0-9]{1,10}$")){

                    Toast.makeText(MainActivity2.this, "1111", Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(MainActivity2.this,MainActivity3.class);
                    intent.putExtra("sf",sf);
                    intent.putExtra("wsdac",wsdac);
                    intent.putExtra("dfsf",dfsf);
                    startActivity(intent);
                } else {
                    Toast.makeText(MainActivity2.this, "", Toast.LENGTH_SHORT).show();
                }
            }
        });

    }
}